<?php

abstract class AApplication
{
    protected $_resources = array();
    
	public function __construct()
	{
	    //Logger
	    $this->logger = $this->engine->load('Log');
	    $writer = Log::createWriter(Log::WRITER_STREAM)->setLogFile(PATH_APP . DS .'debug.log');
        //$writer->setFormatter(Log::createFormatter(Log::FORMAT_XML));
        $this->logger->addWriter($writer, array(Log::ERR));
        
        $this->logger->log('Application Constructor Start', Log::INFO);
        
	    //Debug
	    $this->debug = $this->engine->load('Debug');
	    
	    //Registry
	    $this->registry = $this->engine->load('Registry');
        
        $this->logger->log('Application Constructor End', Log::INFO);
	}
	
	public function __get($key)
	{
	    if(array_key_exists($key,$this->_resources))
	    {
	        return $this->_resources[$key];
	    }
	    else
	    {
	        global $$key;
            if(isset($$key)) return $$key;
            else return false;
	    }
	}
	
	public function __set($key, $value)
	{
	    $this->_resources[$key] = $value;
	}
	
	public function __isset($key)
	{
	    return isset($this->_resources[$key]);
	}
}

?>